﻿@model ChangePassword
<div class="modal fade">
    <div class="modal-dialog modal-lg" id="modalcontent">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span></button>
                <h4 class="modal-title" id="myModalLabel">修改密码</h4>
            </div>
            <div class="modal-body">
                @using (Html.Bootstrap().BeginForm(c => c.Horizontal()))
                {
                    <div class="form-group">
                        @Html.LabelFor(m => m.Password, "原密码：", new { @class = "col-sm-2 control-label" })
                        <div class="col-sm-10">
                            @Html.Bootstrap().PasswordFor(m => m.Password)
                            @Html.ValidationMessageFor(m => m.Password)
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(m => m.PasswordNew, "新密码：", new { @class = "col-sm-2 control-label" })
                        <div class="col-sm-10">
                            @Html.Bootstrap().PasswordFor(m => m.PasswordNew)
                            @Html.ValidationMessageFor(m => m.PasswordNew)
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(m => m.PasswordNewS, "重新输入新密码：", new { @class = "col-sm-2 control-label" })
                        <div class="col-sm-10">
                            @Html.Bootstrap().PasswordFor(m => m.PasswordNewS)
                            @Html.ValidationMessageFor(m=>m.PasswordNewS)
                        </div>
                    </div>

                }
            </div>
            <div class="modal-footer">
                @Html.Bootstrap().Button("修改").Style(BootstrapStyle.Primary).Click("ChangePassword();")
            </div>
        </div>
    </div>
</div>
<script>
    function ChangePassword(url) {

        if (false == $("#modalcontent form").validate().checkForm()) {

            $("#modalcontent form").valid();
            $("#modalcontent form button").button('reset');
            return;
        }
        $.ajax({
            type: "POST",
            url: '@Url.Action("ChangePassword", "Account")',
            data: $("#modalcontent form").serialize(),
            dataType: "json",
            success: function (data) {
                if (data.errors.length > 0) {
                    swal("出错啦！", data.errors, "error");
                }
                else {
                    window.app.message("修改成功");
                    window.app.modalClose();
                }
            }
        });
    }

</script>